<?php
//模块插件类
//插件功能类，由系统调用，实现具体功能。
defined('BY_JYA') or exit('error');
class core_jy_robot extends plugin{
	function start($message,$back){
		//唤醒机器人聊天
		start_context('jy_robot');
		$setting=$this->plugin_setting('chat');
		$answer=$setting['start_message']?$setting['start_message']:'欢迎观临';
		$res=array(
			'MsgType'=>'text',
			'Content'=>$answer,
		);
		return $res;
	}
	function respond($message){
		$question=$message['Content'];//消息内容
		$setting=$this->plugin_setting('chat');
		if($question==$setting['close']){
			end_context();
			$answer=$setting['close_message']?$setting['close_message']:'下次再聊~';
		}else{
			$answer=$this->api($question);
		}
		$res=array(
			'MsgType'=>'text',
			'Content'=>$answer,
		);
		return $res;
	}
}
?>
